package com.xqb.modules.controller.course;

import com.xqb.common.annotation.Log;
import com.xqb.common.core.controller.BaseController;
import com.xqb.common.core.domain.AjaxResult;
import com.xqb.common.core.page.TableDataInfo;
import com.xqb.common.enums.BusinessType;
import com.xqb.common.utils.poi.ExcelUtil;
import com.xqb.modules.domain.po.LesCourseInfo;
import com.xqb.modules.service.ILesCourseInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 上课信息Controller
 * 
 * @author xqb
 * @date 2024-10-14
 */
@RestController
@RequestMapping("/course/info")
public class LesCourseInfoController extends BaseController
{
    @Autowired
    private ILesCourseInfoService lesCourseInfoService;

    /**
     * 查询上课信息列表
     */
    @PreAuthorize("@ss.hasPermi('course:info:list')")
    @GetMapping("/list")
    public TableDataInfo list(LesCourseInfo lesCourseInfo)
    {
        startPage();
        List<LesCourseInfo> list = lesCourseInfoService.selectLesCourseInfoList(lesCourseInfo);
        return getDataTable(list);
    }

    /**
     * 导出上课信息列表
     */
    @PreAuthorize("@ss.hasPermi('course:info:export')")
    @Log(title = "上课信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LesCourseInfo lesCourseInfo)
    {
        List<LesCourseInfo> list = lesCourseInfoService.selectLesCourseInfoList(lesCourseInfo);
        ExcelUtil<LesCourseInfo> util = new ExcelUtil<LesCourseInfo>(LesCourseInfo.class);
        util.exportExcel(response, list, "上课信息数据");
    }

    /**
     * 获取上课信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('course:info:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(lesCourseInfoService.selectLesCourseInfoById(id));
    }

    /**
     * 新增上课信息
     */
    @PreAuthorize("@ss.hasPermi('course:info:add')")
    @Log(title = "上课信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LesCourseInfo lesCourseInfo)
    {
        return toAjax(lesCourseInfoService.insertLesCourseInfo(lesCourseInfo));
    }

    /**
     * 修改上课信息
     */
    @PreAuthorize("@ss.hasPermi('course:info:edit')")
    @Log(title = "上课信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LesCourseInfo lesCourseInfo)
    {
        return toAjax(lesCourseInfoService.updateLesCourseInfo(lesCourseInfo));
    }

    /**
     * 删除上课信息
     */
    @PreAuthorize("@ss.hasPermi('course:info:remove')")
    @Log(title = "上课信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(lesCourseInfoService.deleteLesCourseInfoByIds(ids));
    }
}
